﻿using UnityEngine;

[DisallowMultipleComponent]
public class FullMask : MonoBehaviour
{
    private void Awake()
    {
        ZEventCenter.AddEventListener(ConstData.SCREEN_SIZE_CHANGED, OnScreenSizeChanged);
    }

    private void OnDestroy()
    {
        ZEventCenter.RemoveEventListener(ConstData.SCREEN_SIZE_CHANGED, OnScreenSizeChanged);
    }
    
    public void Start()
    {
        FullScreen();
        enabled = false;
    }
    
    private void OnScreenSizeChanged(ZEvent ev)
    {
        FullScreen();
    }

    private void FullScreen()
    {
        UIWidget full = GetComponent<UIWidget>();
        full.width = GameTool.ScreenWidth;
        full.height = GameTool.ScreenHeight;

        transform.localScale = Vector3.one;
        transform.localPosition = Vector3.zero;
    }
}
